app.service('skuDetailService',['utilService','$q',function(utilService,$q){
    var _this_=this;

    _this_.form={};

    _this_.skuItemsadd=function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'sku/items',
            data:_this_.form
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }


    _this_.deleteSkuItems=function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'sku/items/delete',
            data:{id:$scope.data.id},
            method:"PUT"
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }


    _this_.batchdeleteSkuItems=function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'sku/items/batch/delete',
            data:{ids:$scope.data},
            method:"PUT"
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    _this_.updateSkuItems=function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'sku/items/update',
            data:$scope.data,
            method:"PUT"
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }


    _this_.queryGoodsAboutSkuItemsCount=function($scope,skuItemsId){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + '/sku/items/use/count',
            params:{'skuItemsId':skuItemsId}
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        })
        return deferred.promise;
    }


}]);

